<template>
  <view class="container">
    <!-- 状态栏占位 -->
    <view class="status-bar"></view>
    
    <!-- 头部个人信息 -->
    <view class="header">
      <view class="header-content">
        <text class="title">我的</text>
        <view class="settings-icon" @tap="navigateToSettings">
          <image src="/static/icons/settings.png" class="icon"></image>
        </view>
      </view>
      
      <view class="user-info">
        <image class="avatar" src="/static/images/company-avatar.png"></image>
        <view class="info">
          <text class="name">{{Lname}}</text>
          <view class="meta">
            <text class="member-type">{{type}}会员</text>
            <text class="divider">|</text>
            <view class="rating">
              <image class="star-icon" src="/static/icons/star.png"></image>
              <text class="rating-value">5.0</text>
            </view>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 数据概览卡片 -->
    <view class="stats-card">
      <view class="stat-item">
        <text class="stat-value">28</text>
        <text class="stat-label">已投标项目</text>
      </view>
      <view class="stat-item">
        <text class="stat-value">16</text>
        <text class="stat-label">中标项目</text>
      </view>
      <view class="stat-item">
        <text class="stat-value">96%</text>
        <text class="stat-label">好评率</text>
      </view>
    </view>
    
    <!-- 功能列表 -->
    <view class="content">
      <view class="menu-card">
        <view class="menu-item" @tap="navigateToMyPublish">
          <view class="menu-icon file-icon">
            <image src="/static/icons/file-text.png" class="icon"></image>
          </view>
          <text class="menu-text">我的招标</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
        <view class="menu-item" @tap="navigateToBidList">
          <view class="menu-icon briefcase-icon">
            <image src="/static/icons/briefcase.png" class="icon"></image>
          </view>
          <text class="menu-text">我的投标</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
        <view class="menu-item" @tap="navigateToFavorites">
          <view class="menu-icon bookmark-icon">
            <image src="/static/icons/bookmark.png" class="icon"></image>
          </view>
          <text class="menu-text">我的收藏</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
      </view>
      
      <view class="menu-card">
        <view class="menu-item" @tap="navigateToTransactions">
          <view class="menu-icon wallet-icon">
            <image src="/static/icons/wallet.png" class="icon"></image>
          </view>
          <text class="menu-text">交易记录</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
        <view class="menu-item" @tap="navigateToQualifications">
          <view class="menu-icon badge-icon">
            <image src="/static/icons/badge.png" class="icon"></image>
          </view>
          <text class="menu-text">企业资质</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
        <view class="menu-item" @tap="navigateToHelp">
          <view class="menu-icon help-icon">
            <image src="/static/icons/help-circle.png" class="icon"></image>
          </view>
          <text class="menu-text">关于</text>
          <image src="/static/icons/chevron-right.png" class="arrow"></image>
        </view>
      </view>
      
      <!-- 近期交易 -->
      <view class="recent-transactions">
        <view class="section-header">
          <text class="section-title">近期交易</text>
          <text class="view-all" @tap="navigateToTransactions">查看全部</text>
        </view>
        
        <view class="transaction-card">
          <view class="transaction-item">
            <view class="transaction-icon success-icon">
              <image src="/static/icons/check-circle.png" class="icon"></image>
            </view>
            <view class="transaction-info">
              <view class="transaction-header">
                <text class="transaction-title">某工厂自动化设备采购项目</text>
                <text class="transaction-amount success">+¥180万</text>
              </view>
              <view class="transaction-footer">
                <text class="transaction-type">中标项目</text>
                <text class="transaction-date">2023-05-20</text>
              </view>
            </view>
          </view>
          
          <view class="transaction-item">
            <view class="transaction-icon pending-icon">
              <image src="/static/icons/arrow-right-circle.png" class="icon"></image>
            </view>
            <view class="transaction-info">
              <view class="transaction-header">
                <text class="transaction-title">某公司机械零部件加工项目</text>
                <text class="transaction-amount pending">投标中</text>
              </view>
              <view class="transaction-footer">
                <text class="transaction-type">已投标项目</text>
                <text class="transaction-date">2023-05-10</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 底部导航栏 -->
    <TabBar />
  </view>
</template>

<script setup>
import { ref } from 'vue';
import TabBar from "../../components/TabBar.vue";

import { onLoad} from '@dcloudio/uni-app';


const Lname = ref("");
const type = ref("")

onLoad((options)=>{
 type.value = uni.getStorageSync("type")
 const info = uni.getStorageSync("info")
 console.log("信息：",info)
   if(type.value == "enterprise"){
	   Lname.value = info.company_name
   }else if(type.value == "personal"){
	   Lname.value = info.name
   }
})
// 导航到设置页面
const navigateToSettings = () => {
  uni.navigateTo({
    url: '/pages/profile/settings'
  });
};

// 导航到我的发布页面
const navigateToMyPublish = () => {
  uni.navigateTo({
    url: '/pages/profile/my-publish'
  });
};

// 导航到投标列表页面
const navigateToBidList = () => {
  uni.navigateTo({
    url: '/pages/bid/bid-list'
  });
};

// 导航到收藏页面
const navigateToFavorites = () => {
  uni.navigateTo({
    url: '/pages/profile/favorites'
  });
};

// 导航到交易记录页面
const navigateToTransactions = () => {
  uni.navigateTo({
    url: '/pages/profile/transactions'
  });
};

// 导航到企业资质页面
const navigateToQualifications = () => {
  uni.navigateTo({
    url: '/pages/profile/qualifications'
  });
};

// 导航到帮助中心页面
const navigateToHelp = () => {
  uni.navigateTo({
    url: '/pages/profile/about'
  });
};

// 导航到发布页面
const navigateToPublish = () => {
  uni.navigateTo({
    url: '/pages/bid/bid-publish'
  });
};

// 切换底部标签页
const switchTab = (url) => {
  uni.switchTab({
    url: url
  });
};
</script>

<style>
.container {
  min-height: 100vh;
  background-color: #f5f7fa;
  display: flex;
  flex-direction: column;
  padding-bottom: 40rpx;
}

.status-bar {
  height: var(--status-bar-height);
  width: 100%;
  background-color: #1d4ed8;
}

.header {
  background-color: #1d4ed8;
  padding: 20rpx 30rpx 60rpx;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30rpx;
}

.title {
  font-size: 40rpx;
  font-weight: 600;
  color: #fff;
}

.settings-icon {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 40rpx;
  height: 40rpx;
}

.user-info {
  display: flex;
  align-items: center;
}

.avatar {
  width: 120rpx;
  height: 120rpx;
  border-radius: 60rpx;
  border: 4rpx solid #ffffff;
  margin-right: 20rpx;
}

.info {
  display: flex;
  flex-direction: column;
}

.name {
  font-size: 36rpx;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10rpx;
}

.meta {
  display: flex;
  align-items: center;
}

.member-type {
  font-size: 24rpx;
  color: rgba(255, 255, 255, 0.8);
}

.divider {
  margin: 0 15rpx;
  color: rgba(255, 255, 255, 0.6);
  font-size: 24rpx;
}

.rating {
  display: flex;
  align-items: center;
}

.star-icon {
  width: 24rpx;
  height: 24rpx;
  margin-right: 5rpx;
}

.rating-value {
  font-size: 24rpx;
  color: #ffd700;
}

.stats-card {
  margin: -40rpx 30rpx 30rpx;
  background-color: #fff;
  border-radius: 16rpx;
  padding: 30rpx;
  display: flex;
  justify-content: space-between;
  box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.05);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-value {
  font-size: 40rpx;
  font-weight: 600;
  margin-bottom: 10rpx;
}

.stat-item:nth-child(1) .stat-value {
  color: #1d4ed8;
}

.stat-item:nth-child(2) .stat-value {
  color: #10b981;
}

.stat-item:nth-child(3) .stat-value {
  color: #8b5cf6;
}

.stat-label {
  font-size: 24rpx;
  color: #666;
}

.content {
  flex: 1;
  padding: 0 30rpx 30rpx;
  overflow-y: auto;
}

.menu-card {
  background-color: #fff;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.05);
  margin-bottom: 30rpx;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 30rpx;
  border-bottom: 1px solid #f0f0f0;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-icon {
  width: 80rpx;
  height: 80rpx;
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 20rpx;
}

.file-icon {
  background-color: #dbeafe;
}

.briefcase-icon {
  background-color: #d1fae5;
}

.bookmark-icon {
  background-color: #ede9fe;
}

.wallet-icon {
  background-color: #fff7ed;
}

.badge-icon {
  background-color: #fee2e2;
}

.help-icon {
  background-color: #cffafe;
}

.menu-text {
  flex: 1;
  font-size: 30rpx;
  color: #333;
}

.arrow {
  width: 40rpx;
  height: 40rpx;
  opacity: 0.5;
}

.recent-transactions {
  margin-bottom: 100rpx;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.section-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
}

.view-all {
  font-size: 26rpx;
  color: #1d4ed8;
}

.transaction-card {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 20rpx 30rpx;
  box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.05);
}

.transaction-item {
  display: flex;
  padding: 20rpx 0;
  border-bottom: 1px solid #f0f0f0;
}

.transaction-item:last-child {
  border-bottom: none;
}

.transaction-icon {
  width: 80rpx;
  height: 80rpx;
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 20rpx;
  flex-shrink: 0;
}

.success-icon {
  background-color: #d1fae5;
}

.pending-icon {
  background-color: #dbeafe;
}

.transaction-info {
  flex: 1;
}

.transaction-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10rpx;
}

.transaction-title {
  font-size: 28rpx;
  font-weight: 500;
  color: #333;
  flex: 1;
  margin-right: 10rpx;
}

.transaction-amount {
  font-size: 28rpx;
  font-weight: 600;
}

.transaction-amount.success {
  color: #10b981;
}

.transaction-amount.pending {
  color: #666;
}

.transaction-footer {
  display: flex;
  justify-content: space-between;
}

.transaction-type, .transaction-date {
  font-size: 24rpx;
  color: #999;
}

.tabbar {
  height: 110rpx;
  background-color: #fff;
  display: flex;
  align-items: center;
  border-top: 1px solid #f0f0f0;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tab-icon {
  width: 48rpx;
  height: 48rpx;
  margin-bottom: 5rpx;
}

.tab-text {
  font-size: 24rpx;
  color: #999;
}

.tab-item.active .tab-text {
  color: #1d4ed8;
}

.publish {
  position: relative;
  height: 100%;
}

.publish-btn {
  position: absolute;
  top: -40rpx;
  left: 50%;
  transform: translateX(-50%);
  width: 100rpx;
  height: 100rpx;
  background-color: #1d4ed8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6rpx 20rpx rgba(29, 78, 216, 0.3);
}

.publish-icon {
  width: 50rpx;
  height: 50rpx;
}
</style>